package glassline;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Glass {
	public enum GlassActivity {
		Cut,
		// What has been done to this glass?
	}
	public List<GlassActivity> activity = Collections.synchronizedList(new ArrayList<GlassActivity>());
	
	public enum WorkStation {
		CrossSeamer,
		// etc, any workstations or components that may or may not operate on the glass.
	}
	
	// TODO: Adapt this to the capabilities of the animation
	public enum GlassShape {
		Circle,
		Rect,
		Square,
		Triangle,
	}
	
	public enum GlassCondition {
		//Raw, // Glass is only raw while moving from the robot to the conveyor, I don't think this is necessary.
		Broken,
		Processing,
		Done,
	}
	public Map<GlassCondition, Boolean> condition = new HashMap<GlassCondition, Boolean>();
	
	public class GlassRecipe {
		public GlassShape shape;
		public Map<WorkStation, Boolean> workstations = new HashMap<WorkStation, Boolean>();
		
		public GlassRecipe(GlassShape shape, WorkStation[] stations) {
			this.shape = shape;
			
			// Initialize everything to false.
			if (stations != null) {
				for (WorkStation ws : stations) {
					workstations.put(ws, false);
				}
			}
		}
	}
	
	public GlassRecipe recipe;
	
	public Glass(GlassShape shape, WorkStation[] stations) {
		// Initialize all conditions to false.
		for (GlassCondition cond : GlassCondition.values()) {
			condition.put(cond, false);
		}
		
		// Initialize recipe.
		recipe = new GlassRecipe(shape, stations);
	}
	
	public Glass() {}
	
	public void addActivity(GlassActivity ga) {
		activity.add(ga);
	}
	
	/*
	// Should never need this.
	public void removeActivity(GlassActivity ga) {
		activity.remove(ga);
	}
	*/
	
	public void addCondition(GlassCondition gc) {
		condition.put(gc, true);
	}
	
	public void removeCondition(GlassCondition gc) {
		condition.put(gc, false);
	}
	
	// Returns true if it should stop at the specified work station, false otherwise.
	public boolean shouldStopAtStation(WorkStation ws) {
		return this.recipe.workstations.containsKey(ws);
	}
	
	public void printData() {
		System.out.println("Glass activity: " + activity.toString());
		System.out.println("Glass condition: " + condition.toString());
		System.out.println("Recipe shape: " + recipe.shape);
		System.out.println("Recipe workstations: " + recipe.workstations.toString());
	}
}
